#pragma once
#include "reactor/noncopyable.hpp"
#include <vector>
#include <map>

struct epoll_event;

namespace reactor {
class Channel;

/**
 * @brief epoll 系统调用的封装
 */
class Epoll : noncopyable {
public:
    Epoll();
    ~Epoll();

    // 等待事件，并将活跃的 Channel 放入 activeChannels
    void poll(std::vector<Channel*>& activeChannels);
    // 更新 Channel 的事件
    void updateChannel(Channel* channel);
    // 移除 Channel
    void removeChannel(Channel* channel);

private:
    int _epollfd;
    std::vector<struct epoll_event> _events;
    std::map<int, Channel*> _channels; // fd -> Channel*
};
} // namespace reactor
